package com.atguigu.test;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * @author yihu
 * @create 2021-06-21 11:27
 * @email:1057202547@qq.com
 * @dec:
 */
public class Typetoken<T> {

    String name;
    int age;

    protected  Typetoken(){
        System.out.println("父类 protected构造器调用");
    }

    public  void show(){
        System.out.println("父类");
        System.out.println(this);  //this 继承当前类的实例
        Type superclass = this.getClass().getGenericSuperclass(); //当前类
        System.out.println(superclass);
        ParameterizedType parameterized = (ParameterizedType)superclass;
        //获取泛型的类型
        Type[] actualTypeArguments = parameterized.getActualTypeArguments();
        for (Type t : actualTypeArguments){
            System.out.println(t);
        }
    }
}
